﻿<Window x:Class="ResourceBlender_Express.WinGenerate"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:sys="clr-namespace:System;assembly=mscorlib"
    xmlns:loc="clr-namespace:ResourceBlender_Express"
    xmlns:validators="clr-namespace:ResourceBlender_Express.Validators"
    xmlns:props="clr-namespace:ResourceBlender_Express.Properties"
    loc:WindowService.EscapeClosesWindow="True"
    Title="Generate Resources" 
    Height="470" Width="500" 
    MinWidth="450" MinHeight="400"
    Loaded="Window_Loaded"
    WindowStartupLocation="CenterOwner"
    Style="{StaticResource {x:Type Window}}" SizeToContent="WidthAndHeight">
    <Window.CommandBindings>
        <CommandBinding Command="ApplicationCommands.SaveAs" Executed="BrowseForFile" />
        <CommandBinding Command="NavigationCommands.Refresh" Executed="RefreshApplications" />
        <CommandBinding Command="loc:WinGenerate.GenerateResources" Executed="GenerateResourcesHandler" />
        <CommandBinding Command="ApplicationCommands.Close" Executed="CloseWindow" />
        <CommandBinding Command="loc:WinGenerate.UpdateFilename" Executed="UpdateFilenameHandler" />
    </Window.CommandBindings>
    <Window.Resources>
        <ResourceDictionary>
            <props:Settings x:Key="settings" />
        </ResourceDictionary>
    </Window.Resources>
    <Grid Margin="6" DataContext="{StaticResource settings}">
        <Grid.RowDefinitions>
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        
        <GroupBox Grid.Row="0" Grid.Column="0" Header="Select Components" MinHeight="100">
            <loc:ApplicationSelector x:Name="applicationSelector" SelectionChanged="TriggerUpdateFilename" />
        </GroupBox>
        
        <GroupBox Grid.Row="1" Grid.Column="0" Header="Options">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition />
                    <RowDefinition />
                </Grid.RowDefinitions>
                
                <Label Grid.Row="0" Grid.Column="0">Completion Threshold (Percent)</Label>
                <TextBox Grid.Row="0" Grid.Column="1" x:Name="txtThreshold">
                    <Binding Path="Default.DefaultThreshold" Mode="TwoWay">
                        <Binding.ValidationRules>
                            <validators:IntegerRangeValidationRule
                                    MinValue="0"
                                    MaxValue="100"
                                    IsGeneric="False" />
                        </Binding.ValidationRules>
                    </Binding>
                </TextBox>
                <CheckBox Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" x:Name="chkIncludeSummary" Margin="2"
                          IsChecked="{Binding Path=Default.IncludeSummary,Mode=TwoWay}">
                    Include Summary
                </CheckBox>
            </Grid>
        </GroupBox>
        <GroupBox Grid.Row="2" Grid.Column="0" Header="Output Format">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition />
                    <RowDefinition />
                </Grid.RowDefinitions>
                
                <ListBox Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="3" x:Name="lstFormat" Style="{StaticResource RadioListTemplate}"
                         ItemsSource="{Binding}" SelectedValuePath="Value" DisplayMemberPath="Key" MinHeight="120">
                </ListBox>
                <Label Grid.Row="1" Grid.Column="0">Output file</Label>
                <TextBox Grid.Row="1" Grid.Column="1" x:Name="txtOutputPath">
                    <Binding Path="RelativeSource Self" Mode="Default">
                        <Binding.ValidationRules>
                            <validators:StringValidationRule
                                    MinimumLength="4"
                                    ErrorMessage="The output filename must be entered" />
                        </Binding.ValidationRules>
                    </Binding>
                </TextBox>
                <Button Grid.Row="1" Grid.Column="2" Command="ApplicationCommands.SaveAs">Browse...</Button>
            </Grid>
        </GroupBox>

        <Grid Grid.Row="3" Grid.Column="0">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <Button Grid.Column="0" Width="140" Command="NavigationCommands.Refresh">Refresh Applications</Button>
            <Button Grid.Column="2" Width="140" Command="loc:WinGenerate.GenerateResources" IsDefault="True">Generate Resources</Button>
            <Button Grid.Column="3" Width="70" Command="ApplicationCommands.Close" IsCancel="True">Cancel</Button>
        </Grid>
    </Grid>
</Window>
